import java.util.Comparator;
import java.util.PriorityQueue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 徐海涛
 * Date: 2022-02-23
 * Time: 16:21
 */
public class TestDemo3 {
    public static void main(String[] args) {
        new Test() {

            @Override
            public void test() {
                System.out.println("我是重写的test方法");
            }
        }.test();
    }
    PriorityQueue<Integer> pro = new PriorityQueue<>(new Comparator<Integer>() {
        @Override
        public int compare(Integer o1, Integer o2) {
            return 0;
        }
    });







    public static void main1(String[] args) {
        OuterClass2.InnerClass innerClass = new OuterClass2.InnerClass();
        innerClass.test();
    }
}

//匿名内部类
class Test{
    public void test() {
        System.out.println("test()hh!");
    }
}
class OuterClass2{
    public int data1 = 1 ;
    private int data2 = 2 ;
    public static int data3 = 3;
    //静态内部类
    static class InnerClass{
        public int data4 = 4;
        private  int data5 = 5;
        public static int data6 = 6;
        public void test() {
            System.out.println(new OuterClass2().data1);
            //System.out.println(data2);data2是私有如要访问需构造get和set方法
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
            System.out.println("InnerClass:test()");
        }
    }
}





class OuterClass{
    public int data1 =1;
    private int data2 = 2;
    public static int data3 = 3;
    //实例内部类：你可以把他当做 是外部类的一个实例成员
    class InnerClass{
        public int data1 = 9999;
        public int data4 = 4;
        private int data5 = 5;
        public static final  int data6 = 6;
        public InnerClass(){
            System.out.println("不带参数的内部类构造方法");
        }
        public void test() {
            System.out.println(OuterClass.this.data1);
            System.out.println(this.data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
            System.out.println("InnerClass:test()");
        }
    }
    public static void main1(String[] args) {
        OuterClass outerClass = new OuterClass();//实例外部类的对象
        //实例内部类的对象 外部类 类名.内部类的类名
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        innerClass.test();
    }





    public void func1() {
        System.out.println("OuterClass:func1()");
    }
}
